<!--
 * @Description: WebSocket
 * @Author: rendc
 * @Date: 2025-11-14 11:22:30
 * @LastEditors: rendc
 * @LastEditTime: 2025-11-14 11:32:17
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>WebSocket</title>
</head>
<body>
  WebSocket
</body>
<script>
  // 新建一个websocket连接 
  var socket = new WebSocket("ws://172.16.0.9:29000/ws/B5/status/push/");
  console.log('🤡 CC - socket:', socket);
  socket.onopen = function(e){
    // 连接成功
    console.log('🤡 CC - e:', e);
    // 可以给websocket发送消息了
  }
  socket.onmessage = function(e){
    // 接收消息
    console.log('🤡 CC - e:', e);
  }
  socket.onerror = function(e){
    // 监听失败的事件
    console.log('🤡 CC - e:', e);
  }
  // 关闭socket连接
  socket.close();
  
</script>
</html>